package com.turman.plyopengl

import android.util.Log

object LogUtil {
    const val TAG = "LogU"
    var on = true

    fun v(tag: String = TAG, throwable: Throwable): LogUtil {
        if (on) {
            Log.v(tag, Log.getStackTraceString(throwable))
        }
        return this
    }

    fun v(tag: String = TAG, message: Any?): LogUtil {
        if (on) {
            Log.v(tag, message.toString())
        }
        return this
    }

    fun d(tag: String = TAG, throwable: Throwable): LogUtil {
        if (on) {
            Log.d(tag, Log.getStackTraceString(throwable))
        }
        return this
    }

    fun d(tag: String = TAG, message: Any?): LogUtil {
        if (on) {
            Log.d(tag, message.toString())
        }
        return this
    }

    fun i(tag: String = TAG, throwable: Throwable): LogUtil {
        if (on) {
            Log.i(tag, Log.getStackTraceString(throwable))
        }
        return this
    }

    fun i(tag: String = TAG, message: Any?): LogUtil {
        if (on) {
            Log.i(tag, message.toString())
        }
        return this
    }

    fun w(tag: String = TAG, throwable: Throwable):LogUtil {
        if (on) {
            Log.w(tag, Log.getStackTraceString(throwable))
        }
        return this
    }

    fun w(tag: String = TAG, message: Any?):LogUtil {
        if (on) {
            Log.w(tag, message.toString())
        }
        return this
    }

    fun e(tag: String = TAG, throwable: Throwable): LogUtil {
        if (on) {
            Log.e(tag, Log.getStackTraceString(throwable))
        }
        return this
    }

    fun e(tag: String = TAG, message: Any?): LogUtil {
        if (on) {
            Log.e(tag, message.toString())
        }
        return this
    }

    fun set(b: Boolean): LogUtil {
        on = b
        return this
    }
}